export function audioToText2(data: { voice: any }) {
  return request.post({
    url: "/client/lingxiyun/textToVoice",
    data,
    headers: { "Content-Type": "application/octet-stream" },
  });
}
const testExport = () => {
  const blob = new Blob([e.data], { type: "audio/wav" });

  // 创建一个可下载的链接
  const url = URL.createObjectURL(blob);

  // 创建一个隐藏的 <a> 标签来触发下载
  const a = document.createElement("a");
  a.href = url;
  a.download = "recording.wav"; // 设置下载文件的名称
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);

  // 释放 URL 对象
  URL.revokeObjectURL(url);
};

// testExport()

navigator.clipboard
  .writeText(
    "【验证密码】您的验证码为750928。尊敬的客户，以上验证密码5分钟内有效，请勿泄露或转发他人。"
  )
  .then(() => {
    console.log("Text copied to clipboard");
  });
document.execCommand("copy");

const handleManyRequest = () => {
  let urls = ['', '', '', '', '']

  return new Promise((r) => {
    const num = urls.length
    let index = 0
    const resList: any[] = []//每个请求的响应结果
    let count = 0// 用于记录已经完成的请求数量
    const request = async () => {
      const url = urls[index]
      // 保存下标
      const tempIndex = index
      index++
      try {
        const res = await fetch(url)
        resList[tempIndex] = res
      } catch (error) {
        resList[tempIndex] = error
      } finally {
        count++
        if (count === urls.length) {
          r(resList)
        }
        if (index < Math.min(urls.length, num)) {
          request()
        }
      }
    }
    // 初始化时，同时发起多个请求
    for (let index = 0; index < Math.min(urls.length, num); index++) {
      request()
    }
  })
}

const handleManyRequest2 = () => {
  let urls = ['', '', '', '', ''];

  // 使用Promise.all并行发起所有请求
  const requests = urls.map(url => {
    return fetch(url)
      .then(res => res)
      .catch(error => error);
  });

  return Promise.all(requests);
};